var app = require('../app');
$("#closepage").on('click',function(){

    window.location.href = '/caserecord/index';

});
var case_status = 0,
    scene_type = null,
    case_code = null,
    begin_date = null,
    end_date = null,
    url = '';
var winHeight = $(window).height() -310,
winHeight2 = $(window).height() -270;
$(".with-window").css("height",winHeight);
$(".with-window2").css("height",winHeight2); 
$(window).resize(function() { 
    winHeight = $(window).height() -310;
    winHeight2 = $(window).height() -270;
    $(".with-window").css("height",winHeight);
    $(".with-window2").css("height",winHeight2); 
});
$('[role-click=filter]').on('click', function(){
    case_status = $('[role-ele=status]').val();
    case_code = $("input[name=case_code]").val();
    begin_date = $("input[name=begin_date]").val();
    end_date = $("input[name=end_date]").val();
    scene_type = $('[role-ele=scene_type]').val();
    scene_type ? url="/smsnoticerecord/messagerecord?status="+case_status+"&scene_type="+scene_type : url = "/caserecord/index?case_status="+case_status+"&case_code="+case_code+"&begin_date="+begin_date+"&end_date="+end_date;
    window.location.href = url;
})

$('[role-click=export]').on('click', function(){
    case_status = $('[role-ele=status]').val();
    case_code = $("input[name=case_code]").val();
    begin_date = $("input[name=begin_date]").val();
    end_date = $("input[name=end_date]").val();
    url = "/caserecord/export?case_status="+case_status+"&case_code="+case_code+"&begin_date="+begin_date+"&end_date="+end_date;
    window.location.href = url;
})
var pageStatus = window.location.search.slice(-1);
if(pageStatus == 1){
    $('.page-top-left-btn').removeClass("left-btn-checked");
    $('.page-top-left-btn-course').addClass('left-btn-checked');
    $('.box-main4,.box-main3,.context-box-main').css('display','none');
    $('.box-main4').css('display','flex');
}
$('.progress-node').each(function(){
        if($(this).attr('isShow') == 1){
        $(this).css('color','#1e93f5')
        $(this).find('.progress-node-point').css('background','#1e93f5')
    }else{
        $(this).css('color','#ccc')
        $(this).find('.progress-node-point').css('background','#ccc')
    }
});
$('.progress-node-line').each(function(){
        if($(this).attr('isShow') == 1){
        $(this).css('border-left','2px solid #1e93f5')
        
    }else{
        $(this).css('border-left','2px solid #ccc')
    }
});
$('.page-top-left-btn').on('click',function(){
    $(this).addClass('left-btn-checked').siblings().removeClass("left-btn-checked");
    $('.box-main4,.box-main3,.context-box-main').css('display','none')
    if($(this).attr('type') == "1"){
        $('.box-main1').css('display','block')
    }else if($(this).attr('type') == "3"){
        $('.box-main2').css('display','block')
    }else if($(this).attr('type') == "2"){
        $('.box-main3').css('display','flex')
    }else if($(this).attr('type') == "4"){
        $('.box-main4').css('display','flex')
    }
})

var  defaultFileSrc = $('.caseCheckInfo-main-nav-li').eq(0).attr('filepath')
$('.showFile').attr('src',defaultFileSrc);
$('.caseCheckInfo-main-nav-li').on('click',function(){
    var fileSrc = $(this).attr('filepath')
    $('.showFile').attr('src',fileSrc)
    $('.caseCheckInfo-main-nav-li-img-box').removeClass('caseCheckInfo-main-nav-li-img-box-checked');
    $('.caseCheckInfo-main-nav-li-name').removeClass('caseCheckInfo-main-nav-li-name-checked');
    $(this).children(".caseCheckInfo-main-nav-li-img-box").addClass('caseCheckInfo-main-nav-li-img-box-checked');
    $(this).children(".caseCheckInfo-main-nav-li-name").addClass('caseCheckInfo-main-nav-li-name-checked');
})
// $('#startTime').daterangepicker({ singleDatePicker: true }, function(start, end, label) {
//     console.log(start.toISOString(), end.toISOString(), label);
// });


// $('#endTime').daterangepicker({ singleDatePicker: true }, function(start, end, label) {
//     console.log(start.toISOString(), end.toISOString(), label);
// });

$("body")
    .on("change", "#user_type", function(){
        $.ajax({
            url: "/Apipublic/getFirm",
            type: "post",
            data: {
                type : $(this).val()
            },
            dataType: "json",
            success: function(res){
                if(res.code == 200){
                    // $('#firmDdata').empty();
                    console.log(res)
                    var qtStr1 = '<option value="0">请选择</option>';
                    for(k = 0;k<res.data.length;k++){
                        console.log('sss')
                        qtStr1 += '<option value="' +res.data[k].id+ '">'+res.data[k].name +'</option>'
                    }
                    console.log(qtStr1)
                    $('[name=upload_firm_id]').html(qtStr1);

                }else{
                    toastr.error(res.message);
                }
            },
            error: function(){
                toastr.error("网络错误，请稍候再试");
            }
        })
    })






